import router from "@/router";
import { useUserStore } from "@/store/User";
export const logout = (before?: () => void, after?: () => void) => {
  const userStore = useUserStore();
  before && before();
  localStorage.removeItem("token");

  userStore.routes.forEach((item) => router.removeRoute(item.name));

  userStore.menus = [];
  userStore.username = "";
  router.push("/login");
  after && after();
};
